@isTest
private class CreateInstallApplyDetailControllerTest{

  static testMethod void testMethod1(){
    Account acc = TestUtils.createAccount();
        insert acc;

       ProductStructure__c ps1 = new ProductStructure__c(
        	Classify1__c='生化'
        );
        insert ps1;

          Dealer__c d = new Dealer__c(
        Name = 'xxxxx',
        Only__c = '13455666'

        );
      insert d;

        Brand__c brand = new Brand__c(
            Name = '迈克生物',
            BrandShortName__c = '迈克生物'
            );
        insert brand;

     //创建安装产品
       Product__c  CL = new Product__c();
        CL.ProductStructure__c = ps1.Id;
       // ConfigurationList__c CL = new ConfigurationList__c();
        CL.RecordTypeId =  Utils.getRecordTypeIdByDevNameAndObjName('CompetitorProduct','Product__c');
        CL.Name='日立7020仪器安装所需';
        CL.CRMBrand__c = brand.Id;
        CL.Model__c = 'xxx';

        insert CL;
      
      Product__c  p = new Product__c();
      p.Name = '生化';
      p.Brand__c = '日立';
      p.Category1__c = '仪器';
      p.Category2__c = '生化';
      p.Category3__c = '测试';
      p.SerialNo__c = '10001';
      p.NCCode__c = 'NC1111';
      insert p ;
    //创建安装申请
    InstallationApply__c ia = new InstallationApply__c();
    ia.Instrument__c =CL.Id;
    ia.Hospital__c = acc.Id;
    ia.NEWDealer__c = d.Id;
       ia.InstallEstiDate__c = Date.newInstance(2099, 12, 1);
        ia.InstallsNumber__c = 1;
    insert ia;
    //创建安装必备条件
    
    InstallApprovalDetail__c iad1 = new InstallApprovalDetail__c();
	iad1.InstallApproval__c = ia.Id;
	iad1.Configuration__c = p.Id;
    insert iad1;
    
    PageReference page = new PageReference('/apex/CreateInstallApplyDetailController?id=' + ia.Id);
  	System.Test.setCurrentPage(page);
    CreateInstallApplyDetailController cia = new CreateInstallApplyDetailController(new ApexPages.StandardController(ia));
  	cia.init();
    System.assertEquals(1,cia.iadList.size());
      
   	 cia.name = '生化';
   		cia.Name = '生化';
      cia.Brand = '日立';
      cia.Category1 = '仪器';
      cia.Category2 = '生化';
      cia.Category3 = '测试';
      cia.serial = '10001';
      cia.NCCode = 'NC1111';
      cia.search();
      integer i = 0;
   for(CreateInstallApplyDetailController.InstallApprovalDetailBean isa :cia.newiadList){
   		isa.chk = true;
       i ++;
   } 
	cia.exchange();
    System.assertEquals(1,cia.pList.size());
    cia.save();
      
      
  }


}